/**
 * Created by leiweibo on 7/18/15.
 */

'use strict'
var app = angular.module('patientdoctorcontroller', []);

app.filter('offset', function () {
  return function (input, start) {
    start = parseInt(start, 10);
    return input.slice(start);
  };
});
app.controller('PatientDoctorCtrl', function($scope, $filter, $compile, PatientService, DiseaseService, ProvinceService, HospitalService, OfficeService, DoctorService, $routeParams) {
  var doctorId = $routeParams.param;

  $scope.callServer = function(tableState) {
    $scope.isLoading = true;

    console.log('the doctorId:' + doctorId);

    var pagination = tableState.pagination;
    var pageSize = pagination.number || 20;
    var pageNo = Math.ceil((pagination.start + 1) / pageSize) || 1;

    PatientService.list_by_doctor(pageNo, pageSize, doctorId, function(result) {
      $scope.displayed = result.patients;
      tableState.pagination.numberOfPages = result.pageCount;
      $scope.isLoading = false;
    });

  }
});
